package cn.swh.guguanjia.config;

import cn.swh.guguanjia.interceptor.LoginInterceptor;
import cn.swh.guguanjia.interceptor.ResourceInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/11/3 16:08
 * @Version: 1.0
 */
@Configuration
//@EnableAspectJAutoProxy
public class SpringMvcConfigurer implements WebMvcConfigurer {
    /**
     * 拦截注册
     *
     * @return [registry]
     **/

    @Autowired
    ResourceInterceptor resourceInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns(new String[]{"/mapper/**","/**/*.html"})
                .excludePathPatterns(new String[]{"/notauth.html","/index.html","/login.html","/notlogin.html"});

        registry.addInterceptor(resourceInterceptor)
                .addPathPatterns(new String[]{"/mapper/**","/**/*.html"})
                .excludePathPatterns(new String[]{"/notauth.html","/index.html","/login.html","/notlogin.html","/navbar.html","/sidebar.html"});
    }
}
